#include <pthread.h>

#ifndef __FIFO_H
#define __FIFO_H

#define FIFO_LENGTH (1024*1024)
#define incFifoPtr(i) (((i)+1)%FIFO_LENGTH)

typedef struct FifoElement_S
{
  void * element;
} FifoElement_T;
typedef FifoElement_T * FifoElement;

typedef struct Fifo_S
{
  volatile unsigned int head;
  volatile unsigned int tail;
  unsigned long long int num;
  FifoElement_T queue[FIFO_LENGTH];
} Fifo_T;
typedef Fifo_T * Fifo;

Fifo newFifo(void);
void delFifo(Fifo f);
int isFifoEmpty(Fifo f);
void enqueue(Fifo f, FifoElement e);
void dequeue(Fifo f, FifoElement e);
int nbdequeue(Fifo f, FifoElement e);

#endif
